package com.ruoyi.web.controller.common;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.net.netconf.util.DeviceManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 * @date 2024-11-27 11:01
 */
@Api(tags = "netconf test")
@RestController
@RequestMapping("/netconf")
public class TestNetconfController {

    @Autowired
    private DeviceManager deviceManager;

    @ApiOperation(value = "test", httpMethod = "GET")
    @GetMapping(value = "/test")
    public String test(){
        return "hello netconf";
    }


    @ApiOperation(value = "create", httpMethod = "GET")
    @GetMapping("/create")
    public AjaxResult create(String ip){
        return AjaxResult.success(deviceManager.getDevice(ip));
    }

    @ApiOperation(value = "close", httpMethod = "GET")
    @GetMapping("/close")
    public AjaxResult close(String ip){
        deviceManager.closeDevice(ip);
        return AjaxResult.success();
    }

    // getStatus
    @ApiOperation(value = "getStatus", httpMethod = "GET")
    @GetMapping("/getStatus")
    public AjaxResult getStatus(String xml){
       return AjaxResult.success(deviceManager.getStatus(xml));
    }

    // getConf
    @ApiOperation(value = "get", httpMethod = "GET")
    @GetMapping("/get")
    public AjaxResult getConf(String xml){
        return AjaxResult.success(deviceManager.getConfig(xml));
    }

    // editConf
    @ApiOperation(value = "edit", httpMethod = "GET")
    @GetMapping("/edit")
    public AjaxResult editConf(String xml, String laodType){
        return AjaxResult.success(deviceManager.editConfig(xml, laodType));
    }

    // deleteConf

    // copyconf
}
